package com.example.demo.Controller;

import com.example.demo.Bean.InsertComment;
import com.example.demo.Bean.UserOrders;
import com.example.demo.Service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UserController {
    @Autowired
    private UserService userService;

    @GetMapping("/getUserOrders")
    public List<UserOrders> getUserOrders(String username){
        return userService.getAllUserOrders(username);
    }

    @PostMapping("updateUserOrderStatus")
    public Boolean updateUserOrderStatus(Integer id){
        try{
            userService.updateUserOrderStatus(id);
            return true;
        }catch (Exception e){
            return false;
        }
    }

    @PostMapping("insertComment")
    public Boolean insertComment(InsertComment insertComment){
        try{
            userService.insertComment(insertComment);
            return true;
        }catch (Exception e){
            return false;
        }
    }
}
